package com.example.grpc.provider.service;


import com.example.grpc.generator.HelloRequest;
import com.example.grpc.generator.HelloResponse;
import com.example.grpc.generator.HelloServiceGrpc;
import io.grpc.stub.StreamObserver;
import net.devh.boot.grpc.server.service.GrpcService;

/**
 * @author liyuncong
 * @version 1.0
 * @file HelloServiceImpl
 * @brief HelloServiceImpl
 * @details HelloServiceImpl
 * @date 2022-11-08
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                        NAME               DESCRIPTION
 * 2022-11-08                  liyuncong          Created
 */
@GrpcService
public class HelloServiceImpl extends HelloServiceGrpc.HelloServiceImplBase {

    @Override
    public void hello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
        final String result = "Hello : " + request.getName() + request.getGender();
        HelloResponse response = HelloResponse
            .newBuilder()
            .setGreeting(result)
            .build();
        responseObserver.onNext(response);
        responseObserver.onCompleted();
    }
}
